package com.example.by.test;

/**
 * Created by BY on 2016/4/20.
 */
public class Listener {
    private ZbyListener listener;
    public Listener(){
        new CountThread().start();
    }

    public void setOnZbyListener(ZbyListener zbyListener) {
        this.listener = zbyListener;
    }

    interface ZbyListener {
        void setRotate(int x);
    }

    class CountThread extends Thread {
        @Override
        public void run() {
            try {
                for (int i = 0; i < 100; i++) {
                    Thread.sleep(200);
                    if (listener != null) {
                        listener.setRotate(i);
                    }
                }
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
